package com.itheima.utils;//package com.sky.utils;
//
//import com.aliyun.oss.OSS;
//import com.aliyun.oss.OSSClientBuilder;
//import com.sky.properties.MinioProperties;
//import io.minio.BucketArgs;
//import io.minio.MinioClient;
//import io.minio.ObjectWriteArgs;
//import io.minio.PutObjectArgs;
//import lombok.AllArgsConstructor;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.ByteArrayInputStream;
//import java.io.InputStream;
//import java.io.OutputStreamWriter;
//
//@Data
//@AllArgsConstructor
//@NoArgsConstructor
//@Slf4j
////@Component
//public class MinioUtil {
//    @Autowired
//    private MinioClient minioClient;
//
//    @Autowired
//    private MinioProperties minioProperties;
//
//    public String upload(byte[] bytes, String objectName) {
//        String endpoint = minioProperties.getEndpoint();
//        String bucketName = minioProperties.getBucketName();
//
//        try {
//            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
//                    .bucket(bucketName)
//                    .object(objectName)
//                    .stream(new ByteArrayInputStream(bytes), bytes.length, -1).build();
//
//            //文件名称相同会覆盖
//            minioClient.putObject(putObjectArgs);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return null;
//        }
//
//        String url = endpoint + "/" + bucketName + "/" + objectName;
//        return url;
//    }
//
//
//
//}
